package com.whatever.slip.jczq;

import com.whatever.lottery.jczq.Bet;
import com.whatever.lottery.jczq.Pass;

public class SlipJCZQ {
	
	public static String parse(Bet bet, int type) throws Exception{
		Pass pass = Pass.valueOf("PASS"+bet.getPass().replace('*', '_'));
		int itemCount = bet.getItemList().size();
		
		ISlipJCZQ slip;

        String s = bet.getPlay().toUpperCase();
        if (s.equals("BQC")) {
            if (itemCount <= 3) {
                slip = new SlipJCZQ_BQC3();
            } else {
                slip = new SlipJCZQ_BQC6();
            }

        } else if (s.equals("CBF")) {
            if (itemCount <= 3) {
                slip = new SlipJCZQ_CBF3();
            } else {
                slip = new SlipJCZQ_CBF6();
            }

        } else if (s.equals("JQS")) {
            if (itemCount <= 3) {
                slip = new SlipJCZQ_JQS3();
            } else {
                slip = new SlipJCZQ_JQS6();
            }

        } else {
            if (pass.equals(Pass.PASS1_1)) {
                if (itemCount <= 3) {
                    slip = new SlipJCZQ_SPF3();
                } else if (itemCount <= 6) {
                    slip = new SlipJCZQ_SPF6();
                } else {
                    slip = new SlipJCZQ_SPF8();
                }

            } else if (pass.ordinal() <= Pass.PASS3_4.ordinal()) {
                slip = new SlipJCZQ_SPF3();
            } else if (pass.ordinal() <= Pass.PASS6_57.ordinal()) {
                slip = new SlipJCZQ_SPF6();
            } else {
                slip = new SlipJCZQ_SPF8();
            }
        }
		
		return slip.draw(bet, type);
	}
}
